package com.yxy.controller.mobile;

import com.yxy.common.Result;
import com.yxy.constant.RequestMapperConstant;
import com.yxy.domain.dto.FeedBackDTO;
import com.yxy.domain.vo.IncentiveVO;
import com.yxy.domain.vo.SignVO;
import com.yxy.service.IncentiveService;
import com.yxy.service.SignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(RequestMapperConstant.USER_REQUEST_MAPPER + "sign")
@Slf4j
public class SignController {

    private final SignService signService;
    private final IncentiveService incentiveService;

    public SignController(SignService signService, IncentiveService incentiveService) {
        this.signService = signService;
        this.incentiveService = incentiveService;
    }

    /**
     * 是否打卡
     * @return
     */
    @GetMapping("/verifySign")
    public Result<Boolean> verifySign(Integer id){
        log.info("验证打卡：{}", id);
        Boolean flag = signService.verifySign(id);
        return Result.success("", flag);
    }

    /**
     * 打卡
     * @param id
     * @return
     */
    @PostMapping("/{id}")
    public Result<String> sign(@PathVariable Integer id){
        log.info("打卡：{}", id);
        signService.sign(id);
        return Result.success("打卡成功");
    }

    /**
     * 获取打卡列表
     * @return
     */
    @GetMapping("/list")
    public Result<List<SignVO>> list(Integer id){
        log.info("获取打卡列表：{}", id);
        List<SignVO> voList = signService.list(id);
        return Result.success("", voList);
    }

    /**
     * 获取激励列表
     * @return
     */
    @GetMapping("/incentiveList")
    public Result<List<IncentiveVO>> list(){
        log.info("获取激励列表");
        List<IncentiveVO> voList = incentiveService.list();
        return Result.success("", voList);
    }

}
